FROM golang:1.17-alpine as golang-dev
add main.go /go/src
run cd /go/src/ && \
    go build -o httpserver main.go

FROM tianon/gosu:alpine as gosu

FROM alpine:3
ENV TZ=Asia/Shanghai LANG=C.UTF-8 LC_ALL=C.UTF-8 VERSION=v1.0
COPY --from=golang-dev /go/src/httpserver /opt/httpserver
COPY --from=gosu /gosu /opt/gosu
ADD entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod +x /usr/bin/entrypoint.sh && \
    adduser -D unknown && \
    apk add --no-cache curl tzdata && \
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo "Asia/Shanghai" > /etc/timezone
EXPOSE 8080
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
CMD ["/opt/httpserver"]